package entities;

import java.io.Serializable;


public class IdManager implements Serializable {

	private DataBase db = DataBase.getInstance();

	private static IdManager ID_MANAGER;
	

	private IdManager() {
		if(db.getIdBase().isEmpty()){
			db.getIdBase().put("garageId", 0);
			db.getIdBase().put("masterId", 0);
			db.getIdBase().put("orderId", 0);
		}

	}

	static IdManager getInstance() {
		if (ID_MANAGER == null) {
			ID_MANAGER = new IdManager();
		}
		return ID_MANAGER;
	}
	
	
	Integer getGarageId() {
		Integer i=db.getIdBase().get("garageId")+1;
		db.getIdBase().put("garageId",i);
		return i;
	}
	
	Integer getMasterId(){
		Integer i=db.getIdBase().get("masterId")+1;
		db.getIdBase().put("masterId", i);
		return i;
	}
	
	Integer getOrderId(){
		Integer i=db.getIdBase().get("orderId")+1;
		db.getIdBase().put("orderId", i);
		return i;
	}

}
